package com.baor.service.impl;

import com.baor.dao.SyslogDao;
import com.baor.domain.AdminVo;
import com.baor.domain.SyslogVo;
import com.baor.service.SyslogService;
import com.baor.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
@Service
public class SyslogServiceImpl implements SyslogService {
    @Autowired
    private SyslogDao syslogDao;
    @Override
    public AjaxResult<?> list(Map<String, Object> params) {
        if(params.containsKey("pageIndex")&&params.containsKey("pageSize")){
            int pageIndex= (int) params.get("pageIndex");
            int pageSize = (int) params.get("pageSize");
            params.put("pageIndex",(pageIndex - 1) * pageSize);
            List<SyslogVo> list = this.syslogDao.list(params);
            Map<String,Object> res = this.syslogDao.findPageCount(params);
            res.put("syslogList",list);
            return AjaxResult.success(res);
        }else{
            return AjaxResult.error();
        }
    }

    @Override
    public AjaxResult<?> selectOne(Map<String, Object> params) {
        List<SyslogVo> list = this.syslogDao.list(params);
        return AjaxResult.success(list);
    }
}
